package b3.widget.home.town
{
	import b3.model.*;
	import b3.net.*;
	import b3.scene.home.*;
	import b3.util.*;
	import b3.config.*;
	import b3.widget.*;
	import b3.widget.basic.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;
	import flash.utils.*;

	public class OccupationCountPane extends BasicWidget
	{
		private var occupantText:TextField;
		
		public function OccupationCountPane()
		{
			super();
			//背景
			var OccupantPaneBgr:Class = ResourceHelper.getInstance().getClassByName("AttackPaneBgr");
			var occupantPaneBgr:Sprite = new OccupantPaneBgr();
			addChild(occupantPaneBgr);
			//我所占领城市数
			var occupantTitle:TextField = new TextField();
			occupantTitle.selectable = false;
			occupantTitle.autoSize = TextFieldAutoSize.LEFT;
			occupantTitle.defaultTextFormat = new TextFormat("微软雅黑", 10, 0x000000);
			occupantTitle.text = "我所占领城市数";
			occupantTitle.x = 62;
			occupantTitle.y = 22;
			addChild(occupantTitle);
			occupantText = new TextField();
			occupantText.selectable = false;
			occupantText.autoSize = TextFieldAutoSize.CENTER;
			occupantText.defaultTextFormat = new TextFormat("微软雅黑", 10, 0x000000, true);
			occupantText.x = 95;
			occupantText.y = 34;
			addChild(occupantText);
			PlayerManager.getInstance().me.packageModel.addEventListener(ModelEvent.REFRESH, onRefresh);
			this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			this.mouseChildren = false;
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			HomeScene.getInstance().centerInfoPane.showOperationTip("OperationAttack", "我所占领的城市数", 0x00AAFF);
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
			HomeScene.getInstance().centerInfoPane.clear();
		}
		
		private function onRefresh(event:ModelEvent):void
		{
			var me:Player = PlayerManager.getInstance().me;
			var population:int = me.packageModel.getObjectNum(ObjConfig.OCCUPATION);
			occupantText.text = population.toString();
		}
		
	}
}